package test.excel.config;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;

public class SheetConfig {
    @XmlAttribute
    private String sheetName;

    @XmlAttribute
    private Integer index;

    @XmlAttribute(required = true)
    private String tableName;

    @XmlAttribute
    private boolean header;

    @XmlAttribute
    private int startFrom;

    @XmlElement(name = "column", required = true)
    private List<ColumnConfig> columns = new ArrayList<ColumnConfig>();

    public SheetConfig() {
        //empty
    }

    public SheetConfig(String sheetName, String tableName, boolean header, int startFrom) {
        this.sheetName = sheetName;
        this.tableName = tableName;
        this.header = header;
        this.startFrom = startFrom;
    }

    public SheetConfig(int index, String tableName, boolean header, int startFrom) {
        this.index = index;
        this.tableName = tableName;
        this.header = header;
        this.startFrom = startFrom;
    }

    public String getSheetName() {
        return sheetName;
    }

    public Integer getIndex() {
        return index;
    }

    public String getTableName() {
        return tableName;
    }

    public boolean isHeader() {
        return header;
    }

    public int getStartFrom() {
		return startFrom;
	}

    public List<ColumnConfig> getColumns() {
        return columns;
    }

    public String getIndexOrSheetName() {
        StringBuilder sb = new StringBuilder();

        if (sheetName != null) {
            sb.append("sheetName: " + sheetName);
        } else {
            sb.append("index: " + index);
        }

        return sb.toString();
    }
}
